import {useState} from "react";
import {useSelector,useDispatch} from "react-redux";
import {increment,decrement} from "./store/modules/counterStore";

function App() {
    const {count} = useSelector(state => state.counter)
    const dispatch = useDispatch();
    const [list, setList] = useState([
        {id:1,title:'初始化git仓库'},
        {id:2,title:'修改app.js文件'},
    ])
  return (
    <div >
        <button onClick={()=>dispatch(decrement(2))}>减</button>
        <span>{count}</span>
        <button onClick={()=>dispatch(increment(2))}>加</button>
        {list.map((item, i) => (
            <div key={i}>{item.title}</div>
        ))}
      react...
    </div>
  );
}
/**
 * 1,定义reducer
 * 2,使用createStore方法传入reducer
 * 3，使用store subscribe方法
 * 4，使用store dispatch 提交
 * 5，使用store getState 获取数据
 *
 * */
export default App;
